package cqrtplm.service.impl;

import com.hustcad.plm.pdm.container.model.dto.BatchContainerQueryDTO;
import com.hustcad.plm.pdm.container.model.dto.TypeInthidDTO;
import com.hustcad.plm.pdm.container.model.vo.ContainerCommonQueryVO;
import com.hustcad.plm.pdm.container.service.TyplmContainerExtService;
import cqrtplm.service.RTContainerAndFolderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class RTContainerAndFolderServiceImpl implements RTContainerAndFolderService {
    @Resource
    private TyplmContainerExtService typlmContainerExtService;
    @Override
    public ContainerCommonQueryVO getContainerByName(String name) throws Exception {
        BatchContainerQueryDTO containerQueryDTO = new BatchContainerQueryDTO();
        List<String> containerTypeList = new ArrayList<>();
        containerTypeList.add("product");
        containerTypeList.add("library");
        containerQueryDTO.setContainerTypeList(containerTypeList);
        containerQueryDTO.setName(name);

        List<TypeInthidDTO> excluteInthidList = new ArrayList<>();
        TypeInthidDTO typeInthidDTO = new TypeInthidDTO();
        typeInthidDTO.setContainerType("library");
        List<String> inthidList = new ArrayList<>();
        inthidList.add("ty.inteplm.library.CTyLibrary|risk");
        typeInthidDTO.setInthidList(inthidList);
        containerQueryDTO.setExcluteInthidList(excluteInthidList);

        List<ContainerCommonQueryVO> queryVOPageInfo = typlmContainerExtService.queryContainerByCondition(containerQueryDTO);
        if (queryVOPageInfo==null|| queryVOPageInfo.isEmpty())
            throw new Exception("未找到名称："+name+"的容器！");
        return  queryVOPageInfo.get(0);
    }

}
